package com.atguigu.Partition;

import com.atguigu.Bean.OrderBean;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

public class GroupPartitioner extends Partitioner<OrderBean, NullWritable> {
    /**
     * 重写分区方法
     *
     * @param orderBean
     * @param nullWritable
     * @param i
     * @return
     */
    @Override
    public int getPartition(OrderBean orderBean, NullWritable nullWritable, int i) {
        //参照HashPartitioner的重写方法
        return (orderBean.getOrderId().hashCode() & Integer.MAX_VALUE) % i;
    }
}
